/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package VcardTest;

import java.io.*;
import java.util.ArrayList;
import DataBean.*;

/**
 *
 * @author Oran
 */
public class CSVIO {

    public boolean ReadCSV(String File, ArrayList<Info> List) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(File), "GBK"));

            String[] line = new String[27];
            String getline = null;
            br.readLine();
            while ((getline = br.readLine()) != null) {
                do {
                    getline = getline.concat(",无");
                    line = getline.split(",");
                } while (line.length < 27);

                Info per = new Info();
                Basic bec = new Basic();
                Family fam = new Family();
                Network net = new Network();
                Work work = new Work();

                String name[] = new String[2];
                name[0]=line[0];
                name[1]=null;
                bec.setName(name);
                stu.setTEL(line[1].equals("") ? "无" : line[1]);
                stu.setEMAIL(line[2].equals("") ? "无" : line[2]);
                stu.setBIR(line[3].equals("") ? "无" : line[3]);
                stu.setGROUP(line[4].equals("") ? "无" : line[4]);
                stu.setREMARKS(line[5].equals("") ? "无" : line[5]);

                stu.getWORKMASSAGE().setWORKCOUNTRY(line[6].equals("") ? "无" : line[6]);
                stu.getWORKMASSAGE().setWORKPROVINCE(line[7].equals("") ? "无" : line[7]);
                stu.getWORKMASSAGE().setWORKCITY(line[8].equals("") ? "无" : line[8]);
                stu.getWORKMASSAGE().setWORKADD(line[9].equals("") ? "无" : line[9]);
                stu.getWORKMASSAGE().setWORKUNIT(line[10].equals("") ? "无" : line[10]);
                stu.getWORKMASSAGE().setDEPARTMENT(line[11].equals("") ? "无" : line[11]);
                stu.getWORKMASSAGE().setPOSITION(line[12].equals("") ? "无" : line[12]);
                stu.getWORKMASSAGE().setWORKZIPCODE(line[13].equals("") ? "无" : line[13]);
                stu.getWORKMASSAGE().setWORKTEL(line[14].equals("") ? "无" : line[14]);
                stu.getWORKMASSAGE().setWORKFAX(line[15].equals("") ? "无" : line[15]);

                stu.getNETMASSAGE().setHOMEPAGE(line[16].equals("") ? "无" : line[16]);
                stu.getNETMASSAGE().setQQNUM(line[17].equals("") ? "无" : line[17]);
                stu.getNETMASSAGE().setMSNNUM(line[18].equals("") ? "无" : line[18]);
                stu.getNETMASSAGE().setBACKUPEMAIL(line[19].equals("") ? "无" : line[19]);

                stu.getHOMEMASSAGE().setHOMECOUNTRY(line[20].equals("") ? "无" : line[20]);
                stu.getHOMEMASSAGE().setHOMEPROVINCE(line[21].equals("") ? "无" : line[21]);
                stu.getHOMEMASSAGE().setHOMECITY(line[22].equals("") ? "无" : line[22]);
                stu.getHOMEMASSAGE().setHOMEADD(line[23].equals("") ? "无" : line[23]);
                stu.getHOMEMASSAGE().setHOMEZIPCODE(line[24].equals("") ? "无" : line[24]);
                stu.getHOMEMASSAGE().setHOMETEL(line[25].equals("") ? "无" : line[25]);
                stu.setPHOTOADD(line[26].equals("") ? "无" : line[26]);

                al.add(stu);//在这加上插入函数！！！！
            }
            if (al.isEmpty()) {
                br.close();
                return false;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return true;
    }
}
